package Yi.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Yi.DAO.UsersDao;
import Yi.DAO.UsersDaoFactory;
@WebServlet("/EditServlet")
public class EditServlet extends HttpServlet{

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	private static final long serialVersionUID = 1L;

	private UsersDao UsersDao = UsersDaoFactory.createDAO();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 								 
		request.setCharacterEncoding("utf-8");
		String uName=(String) request.getSession().getAttribute("uName");
		String uPassword=(String) request.getSession().getAttribute("uPassword");
		String uSex=request.getParameter("uSex");
		System.out.println("uSex"+uSex);
		String uAddress=request.getParameter("uAddress");
		System.out.println("uAddress"+uAddress);
		String uPhone=request.getParameter("uPhone");
		System.out.println("uPhone"+uPhone);
	    String erorr=UsersDao.update(uName,uSex,uAddress,uPhone);
	    request.setAttribute("erorr", erorr);
		request.setAttribute("uName", uName);
		//response.encodeRedirectURL("nameServlet");
		request.getRequestDispatcher("custom.jsp").forward(request, response);
	}
}
